//
//  MYXBaseViewController.m
//  meiyinxiang
//
//  Created by apple on 2017/10/17.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

#import "MYXBaseViewController.h"
#import <HexColor.h>
@interface MYXBaseViewController ()

@end

@implementation MYXBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)addCustomerNavBarWithTitle:(NSString *)title{
    UIView *navBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, ScreenWidth, SafeAreaTopHeight)];
    navBackView.backgroundColor = [UIColor colorWithHexString:@"ea4f48"];
    CGFloat offsetY = 20;
    if (IS_IPHONE_X) {
        offsetY = 40;
    }
    UIButton *backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, offsetY, 40, 40)];
    [backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backAct) forControlEvents:UIControlEventTouchUpInside];
    [navBackView addSubview:backBtn];
    [self.view addSubview:navBackView];
    UILabel *titleLabel = [UILabel cz_labelWithText:title fontSize:17 color:[UIColor whiteColor]];
    CGFloat titleWith = 100;
    CGFloat titleOffsetX = (ScreenWidth - 100)/2;
    [titleLabel setFrame:CGRectMake(titleOffsetX, offsetY, titleWith, 40)];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    [navBackView addSubview:titleLabel];
    [navBackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.height.equalTo(@(SafeAreaTopHeight));
    }];

}
- (void)backAct{
    [self.navigationController popViewControllerAnimated:YES];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
